import Vue from "vue";
import Vuex from "vuex";
import user from "./modules/user";

Vue.use(Vuex);

// 仓库初始化配置
const store = new Vuex.Store({
    modules: {
        user,
    },
});

// 在页面离开之前，缓存一下
window.onunload = function() {
    const userJson = JSON.stringify(store.state.user);
    window.localStorage.setItem("user", userJson);
};

export default store;
